{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "company=[\"A\",\"B\",\"C\"]\n",
    "\n",
    "data=pd.DataFrame({\n",
    "\"company\":[company[x] for x in np.random.randint(0,len(company),10)],\n",
    "\"salary\":np.random.randint(5,50,10),\n",
    "\"age\":np.random.randint(15,50,10)\n",
    "}\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>company</th>\n",
       "      <th>salary</th>\n",
       "      <th>age</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>B</td>\n",
       "      <td>21</td>\n",
       "      <td>34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>B</td>\n",
       "      <td>16</td>\n",
       "      <td>35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>A</td>\n",
       "      <td>25</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>C</td>\n",
       "      <td>39</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>A</td>\n",
       "      <td>24</td>\n",
       "      <td>37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>B</td>\n",
       "      <td>42</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>C</td>\n",
       "      <td>17</td>\n",
       "      <td>23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>A</td>\n",
       "      <td>26</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>B</td>\n",
       "      <td>22</td>\n",
       "      <td>28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>A</td>\n",
       "      <td>33</td>\n",
       "      <td>45</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  company  salary  age\n",
       "0       B      21   34\n",
       "1       B      16   35\n",
       "2       A      25   16\n",
       "3       C      39   16\n",
       "4       A      24   37\n",
       "5       B      42   33\n",
       "6       C      17   23\n",
       "7       A      26   31\n",
       "8       B      22   28\n",
       "9       A      33   45"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>salary</th>\n",
       "      <th>age</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>company</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>A</th>\n",
       "      <td>27.00</td>\n",
       "      <td>32.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B</th>\n",
       "      <td>25.25</td>\n",
       "      <td>32.50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C</th>\n",
       "      <td>28.00</td>\n",
       "      <td>19.50</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         salary    age\n",
       "company               \n",
       "A         27.00  32.25\n",
       "B         25.25  32.50\n",
       "C         28.00  19.50"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.groupby(\"company\").agg('mean')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>salary</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>age</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>32.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>17.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>26.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>42.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>21.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>16.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>37</th>\n",
       "      <td>24.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45</th>\n",
       "      <td>33.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     salary\n",
       "age        \n",
       "16     32.0\n",
       "23     17.0\n",
       "28     22.0\n",
       "31     26.0\n",
       "33     42.0\n",
       "34     21.0\n",
       "35     16.0\n",
       "37     24.0\n",
       "45     33.0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.groupby(\"age\").agg('mean')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    15\n",
       "1    43\n",
       "2     6\n",
       "3    42\n",
       "4    41\n",
       "5    41\n",
       "6    15\n",
       "7    34\n",
       "8    35\n",
       "9    34\n",
       "dtype: int32"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.min(axis = 1, skipna = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def top_k(x,k):\n",
    "             ind=np.argpartition(x,-1*k)[-1*k:]\n",
    "             return ind[np.argsort(x[ind])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('A',\n",
       "    company  salary  age\n",
       "  1       A      45   38\n",
       "  5       A      48   24\n",
       "  6       A      37   26\n",
       "  8       A      13   15\n",
       "  9       A      16   31),\n",
       " ('B',\n",
       "    company  salary  age\n",
       "  0       B       6   17\n",
       "  2       B      35   18\n",
       "  3       B      42   44\n",
       "  4       B      20   36),\n",
       " ('C',\n",
       "    company  salary  age\n",
       "  7       C      33   23)]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(data.groupby(\"company\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.read_excel('C:/Users/zhang/Desktop/stock.xls',index_col = 'date' ,date_parser='date')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                 code  rate   price\n",
      "date                               \n",
      "2021-01-04  000001.SZ -0.74 -3.8263\n",
      "2021-01-04  000002.SZ -0.92 -3.2056\n"
     ]
    }
   ],
   "source": [
    "print(df.head(2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "                 code  rate   price\n",
      "date                               \n",
      "2021-01-04  000004.SZ  0.32  1.5459\n",
      "2021-01-04  000009.SZ  0.26  3.4529\n",
      "2021-01-04  000010.SZ  0.14  3.5806\n",
      "2021-01-04  000012.SZ  0.27  3.6585\n",
      "2021-01-04  000019.SZ  0.18  2.4000\n",
      "...               ...   ...     ...\n",
      "2021-01-25  300698.SZ  0.15  1.0260\n",
      "2021-01-25  300709.SZ  0.12  0.2482\n",
      "2021-01-25  300712.SZ  1.06  4.2932\n",
      "2021-01-25  300722.SZ  0.22  0.4313\n",
      "2021-01-25  300724.SZ  2.14  1.4747\n",
      "\n",
      "[18151 rows x 3 columns]\n"
     ]
    }
   ],
   "source": [
    "df1 = df.loc[df['rate']>0.1]\n",
    "print(df1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'date'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32mc:\\vnstudio\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   2896\u001b[0m             \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2897\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2898\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: 'date'",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_2388/1705780520.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf2\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'rate'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m0.1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m&\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mdate_diff\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'date'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'2021-01-25'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\vnstudio\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   2993\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2994\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2995\u001b[1;33m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2996\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2997\u001b[0m                 \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mc:\\vnstudio\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   2897\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2898\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2899\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_maybe_cast_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   2900\u001b[0m         \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmethod\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mmethod\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtolerance\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mtolerance\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   2901\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndim\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msize\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas/_libs/hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: 'date'"
     ]
    }
   ],
   "source": [
    "df2 = df.loc[(df['rate'] > 0.1)& (date_diff(df['date'],'2021-01-25'))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "def date_diff(date1: object, date2: object) -> object:\n",
    "    date1 = time.strptime(date1, \"%Y-%m-%d\")\n",
    "    date2 = time.strptime(date2, \"%Y-%m-%d\")\n",
    "    date1 = datetime.datetime(date1[0], date1[1], date1[2])\n",
    "    date2 = datetime.datetime(date2[0], date2[1], date2[2])\n",
    "    return (date2 - date1).days\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "def dataframe_filter(df: pd.DataFrame, key_col: str, date_col: str, max_adjacent_day: int):\n",
    "    df = df.sort_values([key_col, date_col], ascending=[1, 0])\n",
    "\n",
    "    curr_date = None\n",
    "    curr_key = None\n",
    "    for index, row in df.iterrows():\n",
    "        if curr_key != row['code']:\n",
    "            curr_key = row['code']\n",
    "            curr_date = row['date']\n",
    "            continue\n",
    "\n",
    "        diff = date_diff(row['date'], curr_date)\n",
    "        if diff <= max_adjacent_day:\n",
    "            df.loc[index]['date'] = None\n",
    "        else:\n",
    "            curr_date = row['date']\n",
    "\n",
    "    return df.dropna()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        code        date\n",
      "0  000009.SZ  2021-01-25\n",
      "1  000011.SZ  2021-01-26\n",
      "------------------------------\n",
      "筛选的结果: \n",
      "        code        date\n",
      "0  000009.SZ  2021-01-25\n",
      "1  000011.SZ  2021-01-26\n"
     ]
    }
   ],
   "source": [
    "test_dict = {'code': [\"000009.SZ\",\"000011.SZ\"],'date': ['2021-01-25','2021-01-26']}\n",
    "test_df = pd.DataFrame.from_dict(test_dict)\n",
    "print(test_df)\n",
    "print(\"-\"*30)\n",
    "\n",
    "result_df = dataframe_filter(test_df, \"code\", \"date\", 1)\n",
    "\n",
    "print(\"筛选的结果: \")\n",
    "print(result_df)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "df5=df.filter(\"code == '000009.SZ'\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# df.filter(\"code == '000009.SZ' and \"rate > 0.2\").show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'df5' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_2388/3093244750.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf5\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'df5' is not defined"
     ]
    }
   ],
   "source": [
    "df5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Empty DataFrame\n",
      "Columns: [code, rate, price]\n",
      "Index: []\n"
     ]
    }
   ],
   "source": [
    "print(df['2020-01-25'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021Q1</th>\n",
       "      <td>300720.SZ</td>\n",
       "      <td>-0.55</td>\n",
       "      <td>-2.4123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021Q1</th>\n",
       "      <td>300721.SZ</td>\n",
       "      <td>-1.00</td>\n",
       "      <td>-2.8337</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021Q1</th>\n",
       "      <td>300722.SZ</td>\n",
       "      <td>0.22</td>\n",
       "      <td>0.4313</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021Q1</th>\n",
       "      <td>300723.SZ</td>\n",
       "      <td>-0.27</td>\n",
       "      <td>-0.6063</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021Q1</th>\n",
       "      <td>300724.SZ</td>\n",
       "      <td>2.14</td>\n",
       "      <td>1.4747</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             code  rate   price\n",
       "date                           \n",
       "2021Q1  300720.SZ -0.55 -2.4123\n",
       "2021Q1  300721.SZ -1.00 -2.8337\n",
       "2021Q1  300722.SZ  0.22  0.4313\n",
       "2021Q1  300723.SZ -0.27 -0.6063\n",
       "2021Q1  300724.SZ  2.14  1.4747"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_period('Q').tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "DatetimeIndex(['2021-01-04', '2021-01-04', '2021-01-04', '2021-01-04',\n",
      "               '2021-01-04', '2021-01-04', '2021-01-04', '2021-01-04',\n",
      "               '2021-01-04', '2021-01-04',\n",
      "               ...\n",
      "               '2021-01-25', '2021-01-25', '2021-01-25', '2021-01-25',\n",
      "               '2021-01-25', '2021-01-25', '2021-01-25', '2021-01-25',\n",
      "               '2021-01-25', '2021-01-25'],\n",
      "              dtype='datetime64[ns]', name='date', length=65535, freq=None)\n",
      "<class 'pandas.core.indexes.datetimes.DatetimeIndex'>\n"
     ]
    }
   ],
   "source": [
    "print(type(df))\n",
    "print(df.index)\n",
    "print(type(df.index))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.series.Series'>\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "date\n",
       "2021-01-04    000001.SZ\n",
       "2021-01-04    000002.SZ\n",
       "Name: code, dtype: object"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = pd.Series(df['code'], index=df.index)\n",
    "print(type(s))\n",
    "s.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------获取2021年的数据-----------\n",
      "                 code  rate   price\n",
      "date                               \n",
      "2021-01-04  000001.SZ -0.74 -3.8263\n",
      "2021-01-04  000002.SZ -0.92 -3.2056\n",
      "Empty DataFrame\n",
      "Columns: [code, rate, price]\n",
      "Index: []\n"
     ]
    }
   ],
   "source": [
    "print('---------获取2021年的数据-----------')\n",
    "print(df['2021'].head(2)) # 获取2013年的数据\n",
    "print(df['2020'].tail(2)) # 获取2013年的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------获取2016至2017年的数据-----------\n",
      "                 code  rate   price\n",
      "date                               \n",
      "2021-01-04  000001.SZ -0.74 -3.8263\n",
      "2021-01-04  000002.SZ -0.92 -3.2056\n"
     ]
    }
   ],
   "source": [
    "print('---------获取2016至2017年的数据-----------')\n",
    "print(df['2021-01':'2021-02'].head(2))  #获取2016至2017年的数据\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "---------获取某月的数据-----------\n",
      "Empty DataFrame\n",
      "Columns: [code, rate, price]\n",
      "Index: []\n"
     ]
    }
   ],
   "source": [
    "print('---------获取某月的数据-----------')\n",
    "print(df['2021-12-01']) # 获取某月的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [code, rate, price]\n",
       "Index: []"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['2021-11-06':'2021-11-07']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "truncate requires a sorted index",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_2388/1468155581.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtruncate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mafter\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'2021-11'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\vnstudio\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mtruncate\u001b[1;34m(self, before, after, axis, copy)\u001b[0m\n\u001b[0;32m   9626\u001b[0m         \u001b[1;31m# Check that index is sorted\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   9627\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_monotonic_increasing\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_monotonic_decreasing\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 9628\u001b[1;33m             \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"truncate requires a sorted index\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   9629\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   9630\u001b[0m         \u001b[1;31m# if we have a date index, convert to dates, otherwise\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: truncate requires a sorted index"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>3719.85</td>\n",
       "      <td>-9209.3523</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               rate      price\n",
       "date                          \n",
       "2021-01-31  3719.85 -9209.3523"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.resample('M').sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-10</th>\n",
       "      <td>191.87</td>\n",
       "      <td>-9425.9119</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-17</th>\n",
       "      <td>-618.75</td>\n",
       "      <td>-4784.7386</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-24</th>\n",
       "      <td>4307.39</td>\n",
       "      <td>9927.1840</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-31</th>\n",
       "      <td>-160.66</td>\n",
       "      <td>-4925.8858</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "               rate      price\n",
       "date                          \n",
       "2021-01-10   191.87 -9425.9119\n",
       "2021-01-17  -618.75 -4784.7386\n",
       "2021-01-24  4307.39  9927.1840\n",
       "2021-01-31  -160.66 -4925.8858"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.resample('w').sum().head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>-0.74</td>\n",
       "      <td>-3.8263</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600508.SH</td>\n",
       "      <td>0.06</td>\n",
       "      <td>0.5917</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600509.SH</td>\n",
       "      <td>0.20</td>\n",
       "      <td>3.9448</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600510.SH</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.5891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600511.SH</td>\n",
       "      <td>-1.31</td>\n",
       "      <td>-2.6567</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002200.SZ</td>\n",
       "      <td>-0.14</td>\n",
       "      <td>-2.8340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002201.SZ</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-1.4540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002202.SZ</td>\n",
       "      <td>0.12</td>\n",
       "      <td>0.7134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002190.SZ</td>\n",
       "      <td>0.35</td>\n",
       "      <td>1.3118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300724.SZ</td>\n",
       "      <td>2.14</td>\n",
       "      <td>1.4747</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>65535 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 code  rate   price\n",
       "date                               \n",
       "2021-01-04  000001.SZ -0.74 -3.8263\n",
       "2021-01-04  600508.SH  0.06  0.5917\n",
       "2021-01-04  600509.SH  0.20  3.9448\n",
       "2021-01-04  600510.SH  0.04  0.5891\n",
       "2021-01-04  600511.SH -1.31 -2.6567\n",
       "...               ...   ...     ...\n",
       "2021-01-25  002200.SZ -0.14 -2.8340\n",
       "2021-01-25  002201.SZ -0.18 -1.4540\n",
       "2021-01-25  002202.SZ  0.12  0.7134\n",
       "2021-01-25  002190.SZ  0.35  1.3118\n",
       "2021-01-25  300724.SZ  2.14  1.4747\n",
       "\n",
       "[65535 rows x 3 columns]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df. sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "truncate requires a sorted index",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_2388/1468155581.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtruncate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mafter\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'2021-11'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\vnstudio\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mtruncate\u001b[1;34m(self, before, after, axis, copy)\u001b[0m\n\u001b[0;32m   9626\u001b[0m         \u001b[1;31m# Check that index is sorted\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   9627\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_monotonic_increasing\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_monotonic_decreasing\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 9628\u001b[1;33m             \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"truncate requires a sorted index\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   9629\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   9630\u001b[0m         \u001b[1;31m# if we have a date index, convert to dates, otherwise\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: truncate requires a sorted index"
     ]
    }
   ],
   "source": [
    "df.truncate(after = '2021-11')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'module' object is not callable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_2388/2487440178.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m<\u001b[0m\u001b[0mdatetime\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2021\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m12\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: 'module' object is not callable"
     ]
    }
   ],
   "source": [
    "df.loc[df.index<datetime(2021,12,1)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-11</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>0.53</td>\n",
       "      <td>2.6700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-11</th>\n",
       "      <td>000002.SZ</td>\n",
       "      <td>0.44</td>\n",
       "      <td>1.4997</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-11</th>\n",
       "      <td>000004.SZ</td>\n",
       "      <td>-1.01</td>\n",
       "      <td>-5.2549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-11</th>\n",
       "      <td>000005.SZ</td>\n",
       "      <td>-0.08</td>\n",
       "      <td>-3.3755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-11</th>\n",
       "      <td>000006.SZ</td>\n",
       "      <td>-0.07</td>\n",
       "      <td>-1.3384</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300720.SZ</td>\n",
       "      <td>-0.55</td>\n",
       "      <td>-2.4123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300721.SZ</td>\n",
       "      <td>-1.00</td>\n",
       "      <td>-2.8337</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300722.SZ</td>\n",
       "      <td>0.22</td>\n",
       "      <td>0.4313</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300723.SZ</td>\n",
       "      <td>-0.27</td>\n",
       "      <td>-0.6063</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300724.SZ</td>\n",
       "      <td>2.14</td>\n",
       "      <td>1.4747</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>57283 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 code  rate   price\n",
       "date                               \n",
       "2021-01-11  000001.SZ  0.53  2.6700\n",
       "2021-01-11  000002.SZ  0.44  1.4997\n",
       "2021-01-11  000004.SZ -1.01 -5.2549\n",
       "2021-01-11  000005.SZ -0.08 -3.3755\n",
       "2021-01-11  000006.SZ -0.07 -1.3384\n",
       "...               ...   ...     ...\n",
       "2021-01-25  300720.SZ -0.55 -2.4123\n",
       "2021-01-25  300721.SZ -1.00 -2.8337\n",
       "2021-01-25  300722.SZ  0.22  0.4313\n",
       "2021-01-25  300723.SZ -0.27 -0.6063\n",
       "2021-01-25  300724.SZ  2.14  1.4747\n",
       "\n",
       "[57283 rows x 3 columns]"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['2021-01-06':'2021-03-06']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "truncate requires a sorted index",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_2388/765752165.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtruncate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mbefore\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'2021-02'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mc:\\vnstudio\\lib\\site-packages\\pandas\\core\\generic.py\u001b[0m in \u001b[0;36mtruncate\u001b[1;34m(self, before, after, axis, copy)\u001b[0m\n\u001b[0;32m   9626\u001b[0m         \u001b[1;31m# Check that index is sorted\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   9627\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_monotonic_increasing\u001b[0m \u001b[1;32mand\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mis_monotonic_decreasing\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 9628\u001b[1;33m             \u001b[1;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"truncate requires a sorted index\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   9629\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   9630\u001b[0m         \u001b[1;31m# if we have a date index, convert to dates, otherwise\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: truncate requires a sorted index"
     ]
    }
   ],
   "source": [
    "df.truncate(before='2021-02')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfsort = df.sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>-0.74</td>\n",
       "      <td>-3.8263</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600508.SH</td>\n",
       "      <td>0.06</td>\n",
       "      <td>0.5917</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600509.SH</td>\n",
       "      <td>0.20</td>\n",
       "      <td>3.9448</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600510.SH</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.5891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600511.SH</td>\n",
       "      <td>-1.31</td>\n",
       "      <td>-2.6567</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002200.SZ</td>\n",
       "      <td>-0.14</td>\n",
       "      <td>-2.8340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002201.SZ</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-1.4540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002202.SZ</td>\n",
       "      <td>0.12</td>\n",
       "      <td>0.7134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002190.SZ</td>\n",
       "      <td>0.35</td>\n",
       "      <td>1.3118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300724.SZ</td>\n",
       "      <td>2.14</td>\n",
       "      <td>1.4747</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>65535 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 code  rate   price\n",
       "date                               \n",
       "2021-01-04  000001.SZ -0.74 -3.8263\n",
       "2021-01-04  600508.SH  0.06  0.5917\n",
       "2021-01-04  600509.SH  0.20  3.9448\n",
       "2021-01-04  600510.SH  0.04  0.5891\n",
       "2021-01-04  600511.SH -1.31 -2.6567\n",
       "...               ...   ...     ...\n",
       "2021-01-25  002200.SZ -0.14 -2.8340\n",
       "2021-01-25  002201.SZ -0.18 -1.4540\n",
       "2021-01-25  002202.SZ  0.12  0.7134\n",
       "2021-01-25  002190.SZ  0.35  1.3118\n",
       "2021-01-25  300724.SZ  2.14  1.4747\n",
       "\n",
       "[65535 rows x 3 columns]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dfsort.truncate(after='2022-06')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [],
   "source": [
    "trainDF_Ascending = df.sort_index(ascending=True) #日期升序\n",
    "trainDF_Descending = df.sort_index(ascending=False) #日期降序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>000001.SZ</td>\n",
       "      <td>-0.74</td>\n",
       "      <td>-3.8263</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600508.SH</td>\n",
       "      <td>0.06</td>\n",
       "      <td>0.5917</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600509.SH</td>\n",
       "      <td>0.20</td>\n",
       "      <td>3.9448</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600510.SH</td>\n",
       "      <td>0.04</td>\n",
       "      <td>0.5891</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-04</th>\n",
       "      <td>600511.SH</td>\n",
       "      <td>-1.31</td>\n",
       "      <td>-2.6567</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002200.SZ</td>\n",
       "      <td>-0.14</td>\n",
       "      <td>-2.8340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002201.SZ</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-1.4540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002202.SZ</td>\n",
       "      <td>0.12</td>\n",
       "      <td>0.7134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002190.SZ</td>\n",
       "      <td>0.35</td>\n",
       "      <td>1.3118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300724.SZ</td>\n",
       "      <td>2.14</td>\n",
       "      <td>1.4747</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>65535 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 code  rate   price\n",
       "date                               \n",
       "2021-01-04  000001.SZ -0.74 -3.8263\n",
       "2021-01-04  600508.SH  0.06  0.5917\n",
       "2021-01-04  600509.SH  0.20  3.9448\n",
       "2021-01-04  600510.SH  0.04  0.5891\n",
       "2021-01-04  600511.SH -1.31 -2.6567\n",
       "...               ...   ...     ...\n",
       "2021-01-25  002200.SZ -0.14 -2.8340\n",
       "2021-01-25  002201.SZ -0.18 -1.4540\n",
       "2021-01-25  002202.SZ  0.12  0.7134\n",
       "2021-01-25  002190.SZ  0.35  1.3118\n",
       "2021-01-25  300724.SZ  2.14  1.4747\n",
       "\n",
       "[65535 rows x 3 columns]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainDF_Ascending.truncate(after='2022-06')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>code</th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-01-06</th>\n",
       "      <td>600508.SH</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-1.8367</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-06</th>\n",
       "      <td>600509.SH</td>\n",
       "      <td>-0.06</td>\n",
       "      <td>-1.0345</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-06</th>\n",
       "      <td>600510.SH</td>\n",
       "      <td>-0.04</td>\n",
       "      <td>-0.5979</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-06</th>\n",
       "      <td>600511.SH</td>\n",
       "      <td>0.07</td>\n",
       "      <td>0.1443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-06</th>\n",
       "      <td>600512.SH</td>\n",
       "      <td>-0.02</td>\n",
       "      <td>-0.6826</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002200.SZ</td>\n",
       "      <td>-0.14</td>\n",
       "      <td>-2.8340</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002201.SZ</td>\n",
       "      <td>-0.18</td>\n",
       "      <td>-1.4540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002202.SZ</td>\n",
       "      <td>0.12</td>\n",
       "      <td>0.7134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>002190.SZ</td>\n",
       "      <td>0.35</td>\n",
       "      <td>1.3118</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-01-25</th>\n",
       "      <td>300724.SZ</td>\n",
       "      <td>2.14</td>\n",
       "      <td>1.4747</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>57283 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 code  rate   price\n",
       "date                               \n",
       "2021-01-06  600508.SH -0.18 -1.8367\n",
       "2021-01-06  600509.SH -0.06 -1.0345\n",
       "2021-01-06  600510.SH -0.04 -0.5979\n",
       "2021-01-06  600511.SH  0.07  0.1443\n",
       "2021-01-06  600512.SH -0.02 -0.6826\n",
       "...               ...   ...     ...\n",
       "2021-01-25  002200.SZ -0.14 -2.8340\n",
       "2021-01-25  002201.SZ -0.18 -1.4540\n",
       "2021-01-25  002202.SZ  0.12  0.7134\n",
       "2021-01-25  002190.SZ  0.35  1.3118\n",
       "2021-01-25  300724.SZ  2.14  1.4747\n",
       "\n",
       "[57283 rows x 3 columns]"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "trainDF_Ascending['2021-01-06':'2021-03-06']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [],
   "source": [
    "ppt=trainDF_Ascending['2021-01-06':'2021-03-06'].groupby('code').sum().sort_values(by='rate').tail(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>rate</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>code</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>688390.SH</th>\n",
       "      <td>86.50</td>\n",
       "      <td>31.0291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300935.SZ</th>\n",
       "      <td>94.14</td>\n",
       "      <td>181.2288</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300896.SZ</th>\n",
       "      <td>99.00</td>\n",
       "      <td>13.8531</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>688536.SH</th>\n",
       "      <td>105.06</td>\n",
       "      <td>24.4842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>688202.SH</th>\n",
       "      <td>112.33</td>\n",
       "      <td>56.6663</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>600519.SH</th>\n",
       "      <td>115.55</td>\n",
       "      <td>5.7699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>300677.SZ</th>\n",
       "      <td>122.30</td>\n",
       "      <td>58.7316</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>688680.SH</th>\n",
       "      <td>135.55</td>\n",
       "      <td>205.9572</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>688617.SH</th>\n",
       "      <td>182.54</td>\n",
       "      <td>246.7551</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>688169.SH</th>\n",
       "      <td>257.00</td>\n",
       "      <td>25.2833</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             rate     price\n",
       "code                       \n",
       "688390.SH   86.50   31.0291\n",
       "300935.SZ   94.14  181.2288\n",
       "300896.SZ   99.00   13.8531\n",
       "688536.SH  105.06   24.4842\n",
       "688202.SH  112.33   56.6663\n",
       "600519.SH  115.55    5.7699\n",
       "300677.SZ  122.30   58.7316\n",
       "688680.SH  135.55  205.9572\n",
       "688617.SH  182.54  246.7551\n",
       "688169.SH  257.00   25.2833"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ppt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-01-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-04\n",
      "code\n",
      "300863.SZ    21.62\n",
      "000661.SZ    24.54\n",
      "688023.SH    25.90\n",
      "688390.SH    28.17\n",
      "300841.SZ    30.77\n",
      "688686.SH    41.00\n",
      "688063.SH    42.39\n",
      "300782.SZ    44.36\n",
      "300896.SZ    51.24\n",
      "300750.SZ    52.99\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "300863.SZ    300863.SZ\n",
      "000661.SZ    000661.SZ\n",
      "688023.SH    688023.SH\n",
      "688390.SH    688390.SH\n",
      "300841.SZ    300841.SZ\n",
      "688686.SH    688686.SH\n",
      "688063.SH    688063.SH\n",
      "300782.SZ    300782.SZ\n",
      "300896.SZ    300896.SZ\n",
      "300750.SZ    300750.SZ\n",
      "Name: code, dtype: object\n",
      "2021-01-05\n",
      "code\n",
      "688608.SH    17.29\n",
      "000568.SZ    17.45\n",
      "688536.SH    17.98\n",
      "603605.SH    18.00\n",
      "688286.SH    20.46\n",
      "000858.SZ    21.93\n",
      "603501.SH    23.01\n",
      "300782.SZ    45.06\n",
      "600519.SH    62.45\n",
      "300841.SZ    88.99\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "688608.SH    688608.SH\n",
      "000568.SZ    000568.SZ\n",
      "688536.SH    688536.SH\n",
      "603605.SH    603605.SH\n",
      "688286.SH    688286.SH\n",
      "000858.SZ    000858.SZ\n",
      "603501.SH    603501.SH\n",
      "300782.SZ    300782.SZ\n",
      "600519.SH    600519.SH\n",
      "300841.SZ    300841.SZ\n",
      "Name: code, dtype: object\n",
      "2021-01-06\n",
      "code\n",
      "600763.SH    12.81\n",
      "688063.SH    12.87\n",
      "300760.SZ    13.78\n",
      "688390.SH    17.50\n",
      "300677.SZ    20.50\n",
      "688169.SH    22.99\n",
      "603392.SH    23.30\n",
      "000661.SZ    32.61\n",
      "600519.SH    40.55\n",
      "300928.SZ    48.98\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "600763.SH    600763.SH\n",
      "688063.SH    688063.SH\n",
      "300760.SZ    300760.SZ\n",
      "688390.SH    688390.SH\n",
      "300677.SZ    300677.SZ\n",
      "688169.SH    688169.SH\n",
      "603392.SH    603392.SH\n",
      "000661.SZ    000661.SZ\n",
      "600519.SH    600519.SH\n",
      "300928.SZ    300928.SZ\n",
      "Name: code, dtype: object\n",
      "2021-01-07\n",
      "code\n",
      "300926.SZ     20.39\n",
      "601888.SH     23.00\n",
      "300927.SZ     27.84\n",
      "600809.SH     28.69\n",
      "688390.SH     31.00\n",
      "688063.SH     31.00\n",
      "600519.SH     40.00\n",
      "300751.SZ     44.00\n",
      "688686.SH     51.10\n",
      "688617.SH    182.56\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "300926.SZ    300926.SZ\n",
      "601888.SH    601888.SH\n",
      "300927.SZ    300927.SZ\n",
      "600809.SH    600809.SH\n",
      "688390.SH    688390.SH\n",
      "688063.SH    688063.SH\n",
      "600519.SH    600519.SH\n",
      "300751.SZ    300751.SZ\n",
      "688686.SH    688686.SH\n",
      "688617.SH    688617.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-08\n",
      "code\n",
      "003026.SZ     6.91\n",
      "688008.SH     7.01\n",
      "000661.SZ     7.09\n",
      "603392.SH     7.40\n",
      "300894.SZ     8.04\n",
      "688027.SH     8.31\n",
      "603087.SH    10.01\n",
      "300677.SZ    10.38\n",
      "603195.SH    17.65\n",
      "688339.SH    19.08\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "003026.SZ    003026.SZ\n",
      "688008.SH    688008.SH\n",
      "000661.SZ    000661.SZ\n",
      "603392.SH    603392.SH\n",
      "300894.SZ    300894.SZ\n",
      "688027.SH    688027.SH\n",
      "603087.SH    603087.SH\n",
      "300677.SZ    300677.SZ\n",
      "603195.SH    603195.SH\n",
      "688339.SH    688339.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-11\n",
      "code\n",
      "002791.SZ    14.85\n",
      "605168.SH    17.82\n",
      "300454.SZ    18.32\n",
      "688363.SH    18.65\n",
      "603290.SH    18.88\n",
      "688016.SH    26.00\n",
      "688202.SH    27.68\n",
      "688200.SH    31.01\n",
      "300677.SZ    31.22\n",
      "688169.SH    72.65\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "002791.SZ    002791.SZ\n",
      "605168.SH    605168.SH\n",
      "300454.SZ    300454.SZ\n",
      "688363.SH    688363.SH\n",
      "603290.SH    603290.SH\n",
      "688016.SH    688016.SH\n",
      "688202.SH    688202.SH\n",
      "688200.SH    688200.SH\n",
      "300677.SZ    300677.SZ\n",
      "688169.SH    688169.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-12\n",
      "code\n",
      "000568.SZ    15.40\n",
      "603195.SH    17.75\n",
      "688536.SH    19.28\n",
      "000799.SZ    19.63\n",
      "601888.SH    20.70\n",
      "688200.SH    22.59\n",
      "300751.SZ    23.70\n",
      "603392.SH    25.55\n",
      "300896.SZ    54.10\n",
      "600519.SH    61.17\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "000568.SZ    000568.SZ\n",
      "603195.SH    603195.SH\n",
      "688536.SH    688536.SH\n",
      "000799.SZ    000799.SZ\n",
      "601888.SH    601888.SH\n",
      "688200.SH    688200.SH\n",
      "300751.SZ    300751.SZ\n",
      "603392.SH    603392.SH\n",
      "300896.SZ    300896.SZ\n",
      "600519.SH    600519.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-13\n",
      "code\n",
      "600436.SH    12.50\n",
      "688339.SH    12.53\n",
      "603129.SH    13.42\n",
      "300677.SZ    14.03\n",
      "300661.SZ    16.00\n",
      "002371.SZ    16.91\n",
      "688608.SH    21.26\n",
      "688656.SH    28.74\n",
      "688686.SH    41.00\n",
      "688169.SH    97.28\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "600436.SH    600436.SH\n",
      "688339.SH    688339.SH\n",
      "603129.SH    603129.SH\n",
      "300677.SZ    300677.SZ\n",
      "300661.SZ    300661.SZ\n",
      "002371.SZ    002371.SZ\n",
      "688608.SH    688608.SH\n",
      "688656.SH    688656.SH\n",
      "688686.SH    688686.SH\n",
      "688169.SH    688169.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-14\n",
      "code\n",
      "688012.SH    13.25\n",
      "688408.SH    13.49\n",
      "688229.SH    13.54\n",
      "688037.SH    14.06\n",
      "688301.SH    14.35\n",
      "688200.SH    20.78\n",
      "688016.SH    21.35\n",
      "688019.SH    29.28\n",
      "688536.SH    40.00\n",
      "688095.SH    42.91\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "688012.SH    688012.SH\n",
      "688408.SH    688408.SH\n",
      "688229.SH    688229.SH\n",
      "688037.SH    688037.SH\n",
      "688301.SH    688301.SH\n",
      "688200.SH    688200.SH\n",
      "688016.SH    688016.SH\n",
      "688019.SH    688019.SH\n",
      "688536.SH    688536.SH\n",
      "688095.SH    688095.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-15\n",
      "code\n",
      "688390.SH    13.01\n",
      "688111.SH    13.76\n",
      "300782.SZ    13.99\n",
      "300661.SZ    14.41\n",
      "688617.SH    15.10\n",
      "300760.SZ    15.99\n",
      "688536.SH    18.89\n",
      "688200.SH    19.11\n",
      "300841.SZ    20.50\n",
      "300850.SZ    24.28\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "688390.SH    688390.SH\n",
      "688111.SH    688111.SH\n",
      "300782.SZ    300782.SZ\n",
      "300661.SZ    300661.SZ\n",
      "688617.SH    688617.SH\n",
      "300760.SZ    300760.SZ\n",
      "688536.SH    688536.SH\n",
      "688200.SH    688200.SH\n",
      "300841.SZ    300841.SZ\n",
      "300850.SZ    300850.SZ\n",
      "Name: code, dtype: object\n",
      "2021-01-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-18\n",
      "code\n",
      "688200.SH    22.96\n",
      "300661.SZ    23.03\n",
      "300782.SZ    24.31\n",
      "300677.SZ    24.40\n",
      "603392.SH    24.60\n",
      "603501.SH    28.60\n",
      "300751.SZ    30.51\n",
      "688317.SH    31.66\n",
      "688111.SH    45.04\n",
      "688536.SH    61.07\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "688200.SH    688200.SH\n",
      "300661.SZ    300661.SZ\n",
      "300782.SZ    300782.SZ\n",
      "300677.SZ    300677.SZ\n",
      "603392.SH    603392.SH\n",
      "603501.SH    603501.SH\n",
      "300751.SZ    300751.SZ\n",
      "688317.SH    688317.SH\n",
      "688111.SH    688111.SH\n",
      "688536.SH    688536.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-19\n",
      "code\n",
      "603489.SH     8.91\n",
      "688005.SH     9.81\n",
      "605111.SH    10.10\n",
      "002977.SZ    10.55\n",
      "300906.SZ    10.71\n",
      "688301.SH    11.47\n",
      "688188.SH    11.82\n",
      "688017.SH    21.60\n",
      "688686.SH    32.00\n",
      "688608.SH    32.98\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "603489.SH    603489.SH\n",
      "688005.SH    688005.SH\n",
      "605111.SH    605111.SH\n",
      "002977.SZ    002977.SZ\n",
      "300906.SZ    300906.SZ\n",
      "688301.SH    688301.SH\n",
      "688188.SH    688188.SH\n",
      "688017.SH    688017.SH\n",
      "688686.SH    688686.SH\n",
      "688608.SH    688608.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-20\n",
      "code\n",
      "688202.SH     27.60\n",
      "300841.SZ     29.33\n",
      "600519.SH     31.22\n",
      "688111.SH     32.25\n",
      "688608.SH     33.32\n",
      "300929.SZ     33.72\n",
      "688536.SH     38.00\n",
      "688339.SH     40.07\n",
      "300896.SZ     50.91\n",
      "300935.SZ    107.54\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "688202.SH    688202.SH\n",
      "300841.SZ    300841.SZ\n",
      "600519.SH    600519.SH\n",
      "688111.SH    688111.SH\n",
      "688608.SH    688608.SH\n",
      "300929.SZ    300929.SZ\n",
      "688536.SH    688536.SH\n",
      "688339.SH    688339.SH\n",
      "300896.SZ    300896.SZ\n",
      "300935.SZ    300935.SZ\n",
      "Name: code, dtype: object\n",
      "2021-01-21\n",
      "code\n",
      "605398.SH    16.55\n",
      "600809.SH    17.00\n",
      "688023.SH    17.56\n",
      "300782.SZ    18.43\n",
      "603345.SH    18.49\n",
      "603392.SH    18.51\n",
      "300896.SZ    21.74\n",
      "300930.SZ    23.37\n",
      "688256.SH    25.60\n",
      "600519.SH    29.37\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "605398.SH    605398.SH\n",
      "600809.SH    600809.SH\n",
      "688023.SH    688023.SH\n",
      "300782.SZ    300782.SZ\n",
      "603345.SH    603345.SH\n",
      "603392.SH    603392.SH\n",
      "300896.SZ    300896.SZ\n",
      "300930.SZ    300930.SZ\n",
      "688256.SH    688256.SH\n",
      "600519.SH    600519.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-22\n",
      "code\n",
      "688111.SH     22.67\n",
      "688363.SH     25.89\n",
      "300932.SZ     29.07\n",
      "300677.SZ     30.01\n",
      "688202.SH     30.48\n",
      "688399.SH     38.33\n",
      "688598.SH     39.22\n",
      "300896.SZ     52.26\n",
      "688169.SH    114.00\n",
      "688680.SH    148.06\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "688111.SH    688111.SH\n",
      "688363.SH    688363.SH\n",
      "300932.SZ    300932.SZ\n",
      "300677.SZ    300677.SZ\n",
      "688202.SH    688202.SH\n",
      "688399.SH    688399.SH\n",
      "688598.SH    688598.SH\n",
      "300896.SZ    300896.SZ\n",
      "688169.SH    688169.SH\n",
      "688680.SH    688680.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-25\n",
      "code\n",
      "002304.SZ    19.28\n",
      "300573.SZ    19.84\n",
      "000858.SZ    20.13\n",
      "000596.SZ    23.30\n",
      "000568.SZ    23.91\n",
      "688063.SH    23.99\n",
      "601888.SH    25.00\n",
      "000661.SZ    25.38\n",
      "688390.SH    39.82\n",
      "600519.SH    95.05\n",
      "Name: rate, dtype: float64\n",
      "code\n",
      "002304.SZ    002304.SZ\n",
      "300573.SZ    300573.SZ\n",
      "000858.SZ    000858.SZ\n",
      "000596.SZ    000596.SZ\n",
      "000568.SZ    000568.SZ\n",
      "688063.SH    688063.SH\n",
      "601888.SH    601888.SH\n",
      "000661.SZ    000661.SZ\n",
      "688390.SH    688390.SH\n",
      "600519.SH    600519.SH\n",
      "Name: code, dtype: object\n",
      "2021-01-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-01-31\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2021-02-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-02-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-03-31\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-04-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-05-31\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-10\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-06-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-07-31\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-08-31\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-09-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-10-31\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-23\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-11-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-01\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-02\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-03\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-04\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-05\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-06\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-07\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-08\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-09\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-10\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-11\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-12\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-13\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-14\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-15\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-16\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-17\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-18\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-19\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-20\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-21\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-22\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-23\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-24\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-25\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-26\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-27\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-28\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-29\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n",
      "2021-12-30\n",
      "Series([], Name: rate, dtype: float64)\n",
      "Series([], Name: code, dtype: object)\n"
     ]
    }
   ],
   "source": [
    "\n",
    "def date_range(start_date,end_date):\n",
    "    for n in range(int((end_date-start_date).days)):\n",
    "        yield start_date+datetime.timedelta(n)\n",
    "\n",
    "\n",
    "\n",
    "start=datetime.datetime(2021,1,1,0,0,0)\n",
    "end=datetime.datetime(2021,12,31,0,0,0)\n",
    "\n",
    "for day in date_range(start, end):\n",
    "    print(day.strftime('%Y-%m-%d'))\n",
    "    ppt=trainDF_Ascending[day:day].groupby('code').sum().sort_values(by='rate').tail(10)\n",
    "    s = pd.Series(ppt['rate'], index=ppt.index)\n",
    "    print(s)\n",
    "    s = pd.Series(ppt.index, index=ppt.index)\n",
    "    print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "688390.SH\n",
      "300935.SZ\n",
      "300896.SZ\n",
      "688536.SH\n",
      "688202.SH\n",
      "600519.SH\n",
      "300677.SZ\n",
      "688680.SH\n",
      "688617.SH\n",
      "688169.SH\n"
     ]
    }
   ],
   "source": [
    "for index, row in ppt.iterrows():\n",
    "    print(index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Empty DataFrame\n",
      "Columns: []\n",
      "Index: [2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, 2021-01-04 00:00:00, ...]\n",
      "\n",
      "[65535 rows x 0 columns]\n"
     ]
    }
   ],
   "source": [
    "x = pd.date_range('20210101', '20210109',freq='D')\n",
    "print(df.filter(x))\n",
    "df5=df.filter(\"code == '000009.SZ'\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('688390.SH', rate     86.5000\n",
      "price    31.0291\n",
      "Name: 688390.SH, dtype: float64)\n",
      "('300935.SZ', rate      94.1400\n",
      "price    181.2288\n",
      "Name: 300935.SZ, dtype: float64)\n",
      "('300896.SZ', rate     99.0000\n",
      "price    13.8531\n",
      "Name: 300896.SZ, dtype: float64)\n",
      "('688536.SH', rate     105.0600\n",
      "price     24.4842\n",
      "Name: 688536.SH, dtype: float64)\n",
      "('688202.SH', rate     112.3300\n",
      "price     56.6663\n",
      "Name: 688202.SH, dtype: float64)\n",
      "('600519.SH', rate     115.5500\n",
      "price      5.7699\n",
      "Name: 600519.SH, dtype: float64)\n",
      "('300677.SZ', rate     122.3000\n",
      "price     58.7316\n",
      "Name: 300677.SZ, dtype: float64)\n",
      "('688680.SH', rate     135.5500\n",
      "price    205.9572\n",
      "Name: 688680.SH, dtype: float64)\n",
      "('688617.SH', rate     182.5400\n",
      "price    246.7551\n",
      "Name: 688617.SH, dtype: float64)\n",
      "('688169.SH', rate     257.0000\n",
      "price     25.2833\n",
      "Name: 688169.SH, dtype: float64)\n"
     ]
    }
   ],
   "source": [
    "# 对于每一行，通过列名name访问对应的元素\n",
    "for row in ppt.iterrows():\n",
    "     print(row) # 输出每一行\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "688390.SH 86.5 31.029099999999996\n",
      "300935.SZ 94.14 181.22880000000004\n",
      "300896.SZ 99.0 13.853100000000001\n",
      "688536.SH 105.06 24.484199999999998\n",
      "688202.SH 112.33000000000001 56.66630000000001\n",
      "600519.SH 115.54999999999998 5.7699\n",
      "300677.SZ 122.30000000000001 58.7316\n",
      "688680.SH 135.55 205.9572\n",
      "688617.SH 182.54000000000002 246.75509999999997\n",
      "688169.SH 257.0 25.283299999999997\n"
     ]
    }
   ],
   "source": [
    "for row in ppt.itertuples():\n",
    "     print(row.Index,getattr(row, 'rate'), getattr(row, 'price')) # 输出每一行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20210101\n",
      "20210102\n",
      "20210103\n",
      "20210104\n",
      "20210105\n",
      "20210106\n",
      "20210107\n",
      "20210108\n",
      "20210109\n",
      "20210110\n",
      "20210111\n",
      "20210112\n",
      "20210113\n",
      "20210114\n",
      "20210115\n",
      "20210116\n",
      "20210117\n",
      "20210118\n",
      "20210119\n",
      "20210120\n",
      "20210121\n",
      "20210122\n",
      "20210123\n",
      "20210124\n",
      "20210125\n",
      "20210126\n",
      "20210127\n",
      "20210128\n",
      "20210129\n",
      "20210130\n",
      "20210131\n",
      "20210201\n",
      "20210202\n",
      "20210203\n",
      "20210204\n",
      "20210205\n",
      "20210206\n",
      "20210207\n",
      "20210208\n",
      "20210209\n",
      "20210210\n",
      "20210211\n",
      "20210212\n",
      "20210213\n",
      "20210214\n",
      "20210215\n",
      "20210216\n",
      "20210217\n",
      "20210218\n",
      "20210219\n",
      "20210220\n",
      "20210221\n",
      "20210222\n",
      "20210223\n",
      "20210224\n",
      "20210225\n",
      "20210226\n",
      "20210227\n",
      "20210228\n",
      "20210301\n",
      "20210302\n",
      "20210303\n",
      "20210304\n",
      "20210305\n",
      "20210306\n",
      "20210307\n",
      "20210308\n",
      "20210309\n",
      "20210310\n",
      "20210311\n",
      "20210312\n",
      "20210313\n",
      "20210314\n",
      "20210315\n",
      "20210316\n",
      "20210317\n",
      "20210318\n",
      "20210319\n",
      "20210320\n",
      "20210321\n",
      "20210322\n",
      "20210323\n",
      "20210324\n",
      "20210325\n",
      "20210326\n",
      "20210327\n",
      "20210328\n",
      "20210329\n",
      "20210330\n",
      "20210331\n",
      "20210401\n",
      "20210402\n",
      "20210403\n",
      "20210404\n",
      "20210405\n",
      "20210406\n",
      "20210407\n",
      "20210408\n",
      "20210409\n",
      "20210410\n",
      "20210411\n",
      "20210412\n",
      "20210413\n",
      "20210414\n",
      "20210415\n",
      "20210416\n",
      "20210417\n",
      "20210418\n",
      "20210419\n",
      "20210420\n",
      "20210421\n",
      "20210422\n",
      "20210423\n",
      "20210424\n",
      "20210425\n",
      "20210426\n",
      "20210427\n",
      "20210428\n",
      "20210429\n",
      "20210430\n",
      "20210501\n",
      "20210502\n",
      "20210503\n",
      "20210504\n",
      "20210505\n",
      "20210506\n",
      "20210507\n",
      "20210508\n",
      "20210509\n",
      "20210510\n",
      "20210511\n",
      "20210512\n",
      "20210513\n",
      "20210514\n",
      "20210515\n",
      "20210516\n",
      "20210517\n",
      "20210518\n",
      "20210519\n",
      "20210520\n",
      "20210521\n",
      "20210522\n",
      "20210523\n",
      "20210524\n",
      "20210525\n",
      "20210526\n",
      "20210527\n",
      "20210528\n",
      "20210529\n",
      "20210530\n",
      "20210531\n",
      "20210601\n",
      "20210602\n",
      "20210603\n",
      "20210604\n",
      "20210605\n",
      "20210606\n",
      "20210607\n",
      "20210608\n",
      "20210609\n",
      "20210610\n",
      "20210611\n",
      "20210612\n",
      "20210613\n",
      "20210614\n",
      "20210615\n",
      "20210616\n",
      "20210617\n",
      "20210618\n",
      "20210619\n",
      "20210620\n",
      "20210621\n",
      "20210622\n",
      "20210623\n",
      "20210624\n",
      "20210625\n",
      "20210626\n",
      "20210627\n",
      "20210628\n",
      "20210629\n",
      "20210630\n",
      "20210701\n",
      "20210702\n",
      "20210703\n",
      "20210704\n",
      "20210705\n",
      "20210706\n",
      "20210707\n",
      "20210708\n",
      "20210709\n",
      "20210710\n",
      "20210711\n",
      "20210712\n",
      "20210713\n",
      "20210714\n",
      "20210715\n",
      "20210716\n",
      "20210717\n",
      "20210718\n",
      "20210719\n",
      "20210720\n",
      "20210721\n",
      "20210722\n",
      "20210723\n",
      "20210724\n",
      "20210725\n",
      "20210726\n",
      "20210727\n",
      "20210728\n",
      "20210729\n",
      "20210730\n",
      "20210731\n",
      "20210801\n",
      "20210802\n",
      "20210803\n",
      "20210804\n",
      "20210805\n",
      "20210806\n",
      "20210807\n",
      "20210808\n",
      "20210809\n",
      "20210810\n",
      "20210811\n",
      "20210812\n",
      "20210813\n",
      "20210814\n",
      "20210815\n",
      "20210816\n",
      "20210817\n",
      "20210818\n",
      "20210819\n",
      "20210820\n",
      "20210821\n",
      "20210822\n",
      "20210823\n",
      "20210824\n",
      "20210825\n",
      "20210826\n",
      "20210827\n",
      "20210828\n",
      "20210829\n",
      "20210830\n",
      "20210831\n",
      "20210901\n",
      "20210902\n",
      "20210903\n",
      "20210904\n",
      "20210905\n",
      "20210906\n",
      "20210907\n",
      "20210908\n",
      "20210909\n",
      "20210910\n",
      "20210911\n",
      "20210912\n",
      "20210913\n",
      "20210914\n",
      "20210915\n",
      "20210916\n",
      "20210917\n",
      "20210918\n",
      "20210919\n",
      "20210920\n",
      "20210921\n",
      "20210922\n",
      "20210923\n",
      "20210924\n",
      "20210925\n",
      "20210926\n",
      "20210927\n",
      "20210928\n",
      "20210929\n",
      "20210930\n",
      "20211001\n",
      "20211002\n",
      "20211003\n",
      "20211004\n",
      "20211005\n",
      "20211006\n",
      "20211007\n",
      "20211008\n",
      "20211009\n",
      "20211010\n",
      "20211011\n",
      "20211012\n",
      "20211013\n",
      "20211014\n",
      "20211015\n",
      "20211016\n",
      "20211017\n",
      "20211018\n",
      "20211019\n",
      "20211020\n",
      "20211021\n",
      "20211022\n",
      "20211023\n",
      "20211024\n",
      "20211025\n",
      "20211026\n",
      "20211027\n",
      "20211028\n",
      "20211029\n",
      "20211030\n",
      "20211031\n",
      "20211101\n",
      "20211102\n",
      "20211103\n",
      "20211104\n",
      "20211105\n",
      "20211106\n",
      "20211107\n",
      "20211108\n",
      "20211109\n",
      "20211110\n",
      "20211111\n",
      "20211112\n",
      "20211113\n",
      "20211114\n",
      "20211115\n",
      "20211116\n",
      "20211117\n",
      "20211118\n",
      "20211119\n",
      "20211120\n",
      "20211121\n",
      "20211122\n",
      "20211123\n",
      "20211124\n",
      "20211125\n",
      "20211126\n",
      "20211127\n",
      "20211128\n",
      "20211129\n",
      "20211130\n",
      "20211201\n",
      "20211202\n",
      "20211203\n",
      "20211204\n",
      "20211205\n",
      "20211206\n",
      "20211207\n",
      "20211208\n",
      "20211209\n",
      "20211210\n",
      "20211211\n",
      "20211212\n",
      "20211213\n",
      "20211214\n",
      "20211215\n",
      "20211216\n",
      "20211217\n",
      "20211218\n",
      "20211219\n",
      "20211220\n",
      "20211221\n",
      "20211222\n",
      "20211223\n",
      "20211224\n",
      "20211225\n",
      "20211226\n",
      "20211227\n",
      "20211228\n",
      "20211229\n",
      "20211230\n"
     ]
    }
   ],
   "source": [
    "def date_range(start_date,end_date):\n",
    "    for n in range(int((end_date-start_date).days)):\n",
    "        yield start_date+datetime.timedelta(n)\n",
    "\n",
    "start=datetime.datetime(2021,1,1,0,0,0)\n",
    "end=datetime.datetime(2021,12,31,0,0,0)\n",
    "\n",
    "for day in date_range(start, end):\n",
    "    print(day.strftime('%Y%m%d'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
